package com.lifeservice.console.service.impl;

import com.lifeservice.common.utils.DateUtils;
import com.lifeservice.common.utils.SnowFlakeUtil;
import com.lifeservice.console.domain.LifeBanner;
import com.lifeservice.console.mapper.LifeBannerMapper;
import com.lifeservice.console.service.ILifeBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 广告配置Service业务层处理
 *
 * @author lifeservice
 * @date 2023-03-03
 */
@Service
public class LifeBannerServiceImpl implements ILifeBannerService {
    @Autowired
    private LifeBannerMapper lifeBannerMapper;

    /**
     * 查询广告配置
     *
     * @param id 广告配置主键
     * @return 广告配置
     */
    @Override
    public LifeBanner selectLifeBannerById(String id) {
        return lifeBannerMapper.selectLifeBannerById(id);
    }

    /**
     * 查询广告配置列表
     *
     * @param lifeBanner 广告配置
     * @return 广告配置
     */
    @Override
    public List<LifeBanner> selectLifeBannerList(LifeBanner lifeBanner) {
        return lifeBannerMapper.selectLifeBannerList(lifeBanner);
    }

    /**
     * 新增广告配置
     *
     * @param lifeBanner 广告配置
     * @return 结果
     */
    @Override
    public int insertLifeBanner(LifeBanner lifeBanner) {
        lifeBanner.setId(SnowFlakeUtil.getInstance().nextId());
        lifeBanner.setCreateTime(DateUtils.getNowDate());
        lifeBanner.setUpdateTime(DateUtils.getNowDate());
        return lifeBannerMapper.insertLifeBanner(lifeBanner);
    }

    /**
     * 修改广告配置
     *
     * @param lifeBanner 广告配置
     * @return 结果
     */
    @Override
    public int updateLifeBanner(LifeBanner lifeBanner) {
        lifeBanner.setUpdateTime(DateUtils.getNowDate());
        return lifeBannerMapper.updateLifeBanner(lifeBanner);
    }

    /**
     * 批量删除广告配置
     *
     * @param ids 需要删除的广告配置主键
     * @return 结果
     */
    @Override
    public int deleteLifeBannerByIds(String[] ids) {
        return lifeBannerMapper.deleteLifeBannerByIds(ids);
    }

    /**
     * 删除广告配置信息
     *
     * @param id 广告配置主键
     * @return 结果
     */
    @Override
    public int deleteLifeBannerById(String id) {
        return lifeBannerMapper.deleteLifeBannerById(id);
    }
}
